<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    ul li:nth-child(3) {
      color: red ;
    }

    /* 2,4,6,8...... */
    ul li:nth-child(2n) {
      color: green;
    }

    /* 1,3,5,7...... */
    ul li:nth-child(2n + 1) {
      color: blue;
    }


    /* 1,5,9... */
    div > div:nth-child(4n + 1) {
      color: orange;
    }

    /* 2,6,10... */
    div > div:nth-child(4n + 2) {
      color: purple;
    }

    /* 3,7,11... */
    div > div:nth-child(4n + 3) {
      color: red;
    }

    /* 4的倍数 */
    div > div:nth-child(4n) {
      color: blue;
    }

    /* 前几个 */
    div > div:nth-child(-n + 5) {
      font-size: 20px;
    }

  </style>
</head>
<body>
  
  <ul>
    <li>列表元素1</li>
    <li>列表元素2</li>
    <li>列表元素3</li>
    <li>列表元素4</li>
    <li>列表元素5</li>
    <li>列表元素6</li>
  </ul>

  <div>
    <div>列表元素1</div>
    <div>列表元素2</div>
    <div>列表元素3</div>
    <div>列表元素4</div>
    <div>列表元素5</div>
    <div>列表元素6</div>
    <div>列表元素7</div>
    <div>列表元素8</div>
    <div>列表元素9</div>
    <div>列表元素10</div>
  </div>

</body>
</html>